package buttons;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import controller.Controller;
import util.reflection.Reflection;
import util.resources.ResourceManager;

/**
 * This class groups radio buttons in a single panel.
 * 
 * 
 * @author Josue Mirtil
 * 
 */
public class RadioButtonGroup implements ActionListener
{
    ButtonGroup myButtons;
    Controller myController;
    JPanel myPanel;

    public RadioButtonGroup()
    {
        myPanel = new JPanel();// this panel might be taken out
        // TODO: make a resource for buttons
        // this portion of code will most likely be deleted.
        /*
         * JRadioButton ColorButton = new JRadioButton("Color Map", true);
         * ColorButton.setActionCommand("0");
         * ColorButton.addActionListener(this); JRadioButton AnimationButton =
         * new JRadioButton("Animation", false);
         * AnimationButton.setActionCommand("1");
         * AnimationButton.addActionListener(this); JRadioButton RootButton =
         * new JRadioButton("solve For Root", false);
         * RootButton.setActionCommand("2"); RootButton.addActionListener(this);
         * JRadioButton FractalButton = new JRadioButton("Fractal", false);
         * FractalButton.setActionCommand("3");
         * FractalButton.addActionListener(this);
         * 
         * myButtons= new ButtonGroup(); myButtons.add(ColorButton);
         * myButtons.add(AnimationButton); myButtons.add(RootButton);
         * myButtons.add(FractalButton);
         * 
         * myPanel.add(ColorButton); myPanel.add(AnimationButton);
         * myPanel.add(RootButton); myPanel.add(FractalButton);
         */
    }

    public void add(JRadioButton radioButton)
    {
        myButtons.add(radioButton);
    }

    public void addAll(Collection<JRadioButton> radioButtons)
    {
        for (JRadioButton radioButton : radioButtons)
        {
            this.add(radioButton);
        }
    }

    public JPanel getInstance()
    {
        Enumeration enumer = myButtons.getElements();
        while (enumer.hasMoreElements())
        {
            myPanel.add((JRadioButton) enumer.nextElement());
        }
        return myPanel;
    }

    @Override
    public void actionPerformed(ActionEvent e)
    {
        /*
         * TODO: If we actually implement this, do something here!
         */
        // myController.chooseModel(Integer.parseInt(e.getActionCommand()));
    }

}
